package com.zheng.client.dubbo;


import com.zheng.client.util.IpUtil;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

@Activate(group = {CommonConstants.CONSUMER})
public class TransportIPFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        String ip=IpUtil.getInstance().getLocalIp();
        RpcContext.getContext().setAttachment("ip",ip);
        IpUtil.getInstance().removeLocal();
        return invoker.invoke(invocation);
    }
}
